home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 3
/
Light ROM 3.iso
/
lightwav
/
arexx
/
multi_p.lwm
< prev
next >
Wrap
Text File
|
1995-09-04
|
5KB
|
191 lines
/* MultiPoints.lwm -- CMD: Multiply Points
* Copyright ⌐ 1995 J. Pehrson. WWW: http://www.hfb.se/~d93jpe/.html
* EMail: d93jpe@t.hfb.se, jpehrson@kuai.se
*
* WHY?
* I wrote this macro because I needed a easy way to do a "line" of points
* for the LightSwarm macro for a project a while ago. (I had to make an
* edge look like melted metal, and added lots of lights with lensflares
* (LightSwarm) to the subdivided edge(this macro) Came out pretty good.
* Maybe overkill, but...)
* And I made the macro as a tutorial in ARexx, since this is my first
* attempt to do anything in the language.
*
* GUI:
* Number of points to add = It's the number of points you want to add
* between all (selected) points
* Use only selected points = If checked, the macro will use only the
* currently selected points. If unchecked
* the macro will add points between all points
* in the layer.
*
* Connect first/last points = This button controls wheather or not the
* first and the last point is going to
* have points added between them.
*
* BUGS:
* ░The order in which you created the points is used, not the order in which
* you selected the points. Can give some undesired results. Will be fixed
* if I find out how to do it...
* ░The progress meter isn't updated correctly. (At least not on my system)
* Maybe it's a question of CPU speed...
*
* DISCLAIMER:
* Use this macro at YOUR own risc... It may blow up your computer, or it
* could destroy the project you've been working on for the last couple
* of years.
* But the macro works for ME! So, use it at YOUR own risc. There.
* No more talk, lets AREXX!
*
* $VER: MultiPoints.lwm v2.1 August 9 1995 LightWave Macro
*/
newpoints = 10
selectpoints = 1
closepoints = 0
macroname = 'Multiply Points v2.1'
prefsname = 'ENV:MPointsLW.prefs'
if (exists(prefsname)) then do
if (~open(prefs, prefsname, 'R')) then break
if (readln(prefs) ~= macroname) then break
parse value readln(prefs) with newpoints selectpoints closepoints from .
call close prefs
end
address = 'LWModelerARexx.port'
L=SHOW('Libraries')
IF POS(address,l) = 0 THEN ADDLIB("LWModelerARexx.port",0)
call addlib("rexxmathlib.library",0,-30,0)
signal on error
signal on syntax
call req_begin macroname
id_Np = req_addcontrol("Number of points to add",'N',0)
id_Ap = req_addcontrol("Use only selected points?",'B',0)
id_Cp = req_addcontrol("Connect first/last points?",'B',0)
call req_setval id_Np, newpoints
call req_setval id_Ap, selectpoints
call req_setval id_Cp, closepoints
if (~req_post()) then do
call req_end
exit
end
newpoints=req_getval(id_Np)
selectpoints=req_getval(id_Ap)
closepoints=req_getval(id_Cp)
call req_end
if (open(prefs, prefsname, 'W')) then do
call writeln prefs, macroname
call writeln prefs, newpoints selectpoints closepoints from
call close prefs
end
gtotpoints=xfrm_begin()
call xfrm_end()
if(selectpoints~=0) then do
call sel_mode(USER)
end
if(xfrm_begin()<2) then do
call notify(1,'!You have to create at least 2 points before running this macro!')
call end_all
exit
end
selpoints = xfrm_begin()
call xfrm_end()
totpoints = (selpoints-1)*newpoints+gtotpoints
if(closepoints~=0) then do
totpoints=totpoints+newpoints+gtotpoints
end
totpoints=substr(totpoints,1,(lastpos('.',totpoints))-1,' ')
newpoints=substr(newpoints,1,(lastpos('.',newpoints))-1,' ')
if totpoints > 65000 then do
if (closepoints~=0) then do
call notify(1,'!'newpoints'x'selpoints' gives 'totpoints' points.',' Too many! Cannot count that high.')
exit
end
call notify(1,'!'newpoints'x'selpoints-1' gives 'totpoints' points.',' Too many! Cannot count that high.')
exit
end
if((selpoints<=2)&(closepoints~=0)) then do
call notify(1,'!Number of sel. points='selpoints'. Will not close first/last points!')
closepoints=0
end
totpoints=0
do i=1 to selpoints-1
call xfrm_begin()
vec1=xfrm_getpos(i)
vec2=xfrm_getpos(i+1)
call xfrm_end()
call time 'R'
call setcomp
call plotpoints
end
if(closepoints~=0) then do
call xfrm_begin()
vec1=xfrm_getpos(1)
vec2=xfrm_getpos(selpoints)
call xfrm_end()
call setcomp
call plotpoints
end
ETA=time('E')
call notify(1,'Whew! I just drew 'totpoints' points in 'ETA' seconds!')
call end_all
exit
syntax:
error:
call end_all
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit
end
plotpoints:
call meter_begin(newpoints,"Generating "newpoints" points")
call add_begin()
do k=1 to newpoints
Xn=X0+Rx0*segment*k
Yn=Y0+Ry0*segment*k
Zn=Z0+Rz0*segment*k
call add_point(Xn' 'Yn' 'Zn)
totpoints=totpoints+1
call meter_step()
end
call add_end()
call meter_end()
return 0
setcomp:
X0=word(vec1,1)
Y0=word(vec1,2)
Z0=word(vec1,3)
X1=word(vec2,1)
Y1=word(vec2,2)
Z1=word(vec2,3)
Rx0=X1-X0
Ry0=Y1-Y0
Rz0=Z1-Z0
Z=sqrt((Rx0**2)+(Ry0**2)+(Rz0**2))
Rx0=Rx0/Z
Ry0=Ry0/Z
Rz0=Rz0/Z
segment=Z/(newpoints+1)
return 0